﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;


namespace YT.UnLock
{
    public partial class frmUnlock : Form
    {
        public frmUnlock()
        {
            InitializeComponent();
            oooo();
        }

        private void oooo()
        {
      
            XmlDocument xmldoc = new XmlDocument();
            string strFieldName = Application.StartupPath + "\\YT_XHProject.exe.Config"; // System.AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
            xmldoc.Load(strFieldName);
            xmldoc = new XmlDocument();
            xmldoc.Load(strFieldName);
            XmlNode oNode1 = xmldoc.SelectSingleNode("//configuration//applicationSettings//YT_XHProject.Properties.Settings//setting[@name='UserName']");
            if (oNode1 != null)
            {
                oNode1.InnerText = oNode1.InnerText;
                oNode1.InnerXml = "<value>" + oNode1.InnerText + "</value>"; ;
            }
            oNode1 = xmldoc.SelectSingleNode("//configuration//applicationSettings//YT_XHProject.Properties.Settings//setting[@name='ServerName']");
            if (oNode1 != null)
            {
                oNode1.InnerText = oNode1.InnerText;
                oNode1.InnerXml = "<value>" + oNode1.InnerText + "</value>"; ;
            }
            oNode1 = xmldoc.SelectSingleNode("//configuration//applicationSettings//YT_XHProject.Properties.Settings//setting[@name='Password']");
            if (oNode1 != null)
            {
                oNode1.InnerText = oNode1.InnerText;
                oNode1.InnerXml = "<value>" + oNode1.InnerText + "</value>"; ;
            }
            oNode1 = xmldoc.SelectSingleNode("//configuration//applicationSettings//YT_XHProject.Properties.Settings//setting[@name='DBName']");
            if (oNode1 != null)
            {
                oNode1.InnerText = oNode1.InnerText;
                oNode1.InnerXml = "<value>" + oNode1.InnerText + "</value>"; ;
            }
            oNode1 = xmldoc.SelectSingleNode("//configuration//applicationSettings//YT_XHProject.Properties.Settings//setting[@name='DemoDate']");
            if (oNode1 != null)
            {
                oNode1.InnerText = "2015-01-01";
                oNode1.InnerXml = "<value>2015-01-01</value>";
            }
            xmldoc.Save(strFieldName);
            MessageBox.Show("注册成功.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); 
         
            this.Close();
            System.Windows.Forms.Application.Exit();
        }
    }
}
